package com.cn.gmall.product.controller;

import com.cn.gmall.common.result.Result;
import com.cn.gmall.model.product.SkuInfo;
import com.cn.gmall.model.product.SpuImage;
import com.cn.gmall.product.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/product")
public class SkuManageController {

    @Autowired
    ManageService manageService;

    /**
     * 保存 sku
     * @param skuInfo
     * @return
     */
    @PostMapping("/saveSkuInfo")
    public  Result saveSkuInfo(@RequestBody SkuInfo skuInfo){
        manageService.saveSkuInfo(skuInfo);
        return  Result.ok();
    }

    /**
     * 根据spuId 获取spuImage 集合
     * @param spuId
     * @return
     */
    @GetMapping("/spuImageList/{spuId}")
    public Result spuImageList(@PathVariable Long spuId){
                List<SpuImage> list= manageService.spuImageList(spuId);
        return  Result.ok(list);
    }

}
